package gameEngine;

import java.lang.Math;
import java.awt.GridLayout;

import javax.swing.BorderFactory;

public class PiecesView extends ViewSon {
	/**
	 * 
	 */
	private static final long serialVersionUID = -2313256672019712388L;
	private int edgeSize;
	PiecesList piecesList;
	protected PieceView[] miniBoard;
	Engine controller;

	public PiecesView(PiecesList _piecesList, Engine _controller) {
		super(new GridLayout(
				(int)Math.sqrt(
					(double)_piecesList.getNumberOfPieces())+1,
				(int)Math.sqrt(
					(double)_piecesList.getNumberOfPieces())+1)
				);
		this.setBorder(BorderFactory.createEtchedBorder());
		piecesList = _piecesList;
		controller = _controller;
		edgeSize = piecesList.getNumberOfPieces();
		miniBoard = new PieceView[edgeSize * edgeSize ];
		for(int i = 1; i<edgeSize; i++) {
			miniBoard[i] = new PieceView(piecesList.getPiece(i), controller);
			this.add(miniBoard[i]);
		}
	}

}

